<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>箭头函数实践</title>
  <style>
    div {
      width: 200px;
      height: 200px;
      background: #bfa;
    }
  </style>
</head>

<body>
  <div id="ad"></div>
  <script>
    let ad = document.getElementById('ad');
    // function里面的this和外面的this一样，所以指向的是ad
    ad.addEventListener('click', function () {
      setTimeout(() => {
        this.style.background = 'pink'; //这里的this和function里面的this一样
      }, 2000)
    })
  </script>
</body>

</html>